package com.zzedu.common.enums;

import java.util.Arrays;

public enum CommonEnums {
    YES(0, "是"),
    NO(1, "否"),
    ;

    CommonEnums(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private int code;

    private String desc;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static CommonEnums getCode(Integer code) {
        if (code == null) {
            return null;
        }
        return Arrays.stream(CommonEnums.values()).filter(e -> e.getCode() == code).findFirst().orElse(null);
    }
}
